﻿
if not Exists(Select * from sysobjects where name = 'Coupon' and Xtype = 'U')
begin

CREATE TABLE [dbo].[Coupon](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Code] [varchar](50) NOT NULL,
	[Description] [nvarchar](max) NULL,
	[ExpirationDate] [datetime] NULL,
	[MaximumUseCount] [int] NULL,
	[UsedCount] [int] NULL,
	[MinimumPurchase] [bigint] NULL,
	[MinimumItemCount] [int] NULL,
	[ProductIdListString] [varchar](max) NULL,
	[ProductCategoryIdListString] [varchar](max) NULL,
	[BrandIdListString] [varchar](max) NULL,
	[CouponTypeId] [int] NOT NULL,
	[Discount] [int] NULL,
	[IsFree] [bit] NOT NULL,
	[VendorCode] [varchar](50) NULL,
	[CreationDate] [datetime] NOT NULL,
	[DiscountPercent] [int] NULL,
	[CreditAmount] [bigint] NULL,
	[LastUpdate] [datetime] NOT NULL,
	[Version] [timestamp] NOT NULL,
	[IsArchived] [bit] NOT NULL,
	CONSTRAINT [PK_Coupon_Id] PRIMARY KEY CLUSTERED 
	(
		[Id] ASC
	)
)

End
Go